home *** CD-ROM | disk | FTP | other *** search
/ Light ROM Gold / Light ROM Gold.iso / arexx / modeler / point2ob.lwm < prev    next >
Text File  |  1993-12-25  |  2KB  |  103 lines

  1. ---------------------------begin "Points2Objects.lwm------------
  2. ----------
  3. /* CMD: Points to Objects                                      *
  4.  * $VER: V1.0                                                 *
  5.  *                                                             *
  6.  * Takes points in FG, object in BG, and replaces points w
  7. ith  *
  8.  * objects in an empty layer.=09=09=09=09=09=09=09=09=09=09=09   */
  9. /* By Darren Reid, =A91993 Innovision Strategic Communications. */
  10.  
  11. =09mxx=3D"LWModelerARexx.port"
  12. =09signal on error
  13. =09signal on syntax
  14. =09mxx_add =3D addlib(mxx,0)
  15. =09call mai
  16. n
  17. =09if (mxx_add) then call remlib(mxx)
  18. =09exit
  19.  
  20. =09syntax:
  21. =09error:
  22. =09t=3DNotify(1,'!Rexx Script Error','@'ErrorText(rc),'Line 'SIGL)
  23. =09if (mxx_add) then call remlib(mxx)
  24. =09exit
  25.  
  26.  
  27. main:
  28.  
  29. syscode =3D "Points To Objects"
  30. tmpnam =3D "t:P2O.tmp"
  31.  
  32. /* Use xfrm mode t
  33. o scan through points, storing coordinates to tmp file.
  34.  */
  35. if (~open(plist, tmpnam, 'W')) then return
  36.  
  37. n =3D xfrm_begin()
  38. if (n =3D 0) then do
  39.     call close(plist)
  40.     return
  41. end
  42.  
  43. call meter_b
  44. egin(n, syscode, "Reading Points")
  45. do i=3D1 to n
  46.     call writeln(plist, xfrm_getpos(i))
  47.     call meter_step()
  48. end i
  49. call meter_end()
  50. call xfrm_end()
  51.  
  52. call close(plist)
  53.  
  54. /* Get object data from current BG layer */
  55. orignl =3D CURLAYER()
  56. bglayer =3D CURBLAYER()
  57. call SETLAYER(bglayer)
  58. box =3D BOUNDINGBOX()
  59. parse var box garbage x1 x2 y1 y2 z1 z2
  60. cx=3D(x2+x1)/2
  61. cy=3D(y2+y1)/2
  62. cz=3D(z2+z1)/2
  63. call COPY
  64. call SETLAYER(orignl)
  65.  
  66.  
  67. /* Goto an empty layer.  If none, replace current data.
  68.  */
  69. emp =3D emptylaye
  70. rs()
  71. if (words(emp) =3D 0) then call delete()
  72. else call setlayer(word(emp,1))
  73. worklayer =3D CURLAYER()
  74. call SETLAYER(bglayer)
  75. if (words(emp) < 2) then call delete()
  76. else call setlayer(word(emp,2))
  77. scratchlayer =3D CURLAYER()
  78.  
  79. /* Read the point coordinates back in and create new data consisting
  80.  * of objects.
  81.  */
  82. if (~open(pli
  83. st, tmpnam, 'R')) then return
  84. do i=3D1 to n
  85.     vector =3D readln(plist)
  86.     parse var vector x y z
  87.     dx =3D (x - cx)
  88.     dy =3D (y - cy)
  89.     dz =3D (z - cz)
  90.     cx =3D (cx + 
  91. dx)
  92.     cy =3D (cy + dy)
  93.     cz =3D (cz + dz)
  94.     call PASTE()
  95.     call MOVE(dx dy dz)
  96.     call CUT()
  97.     call SETLAYER(worklayer)
  98.     call PASTE()
  99.     call SETLAYER(scratchlayer)
  100. end i
  101. call SETLAYER(worklayer)
  102. return
  103.